Skip to main content
Version: 1.0.0

Operators

Muze provides some operators which is needed to do various operations like creating shared fields or sanitize html strings.

To access operators,

const Operators = muze.Operators;

html

Syntax: htmltemplateString``

A string template tagged function which sanitizes input html formatted string according to the allowed html tags. This is used to render html in canvas components like title and tooltip.

Parameters:

PropertyTypeRequiredDefaultDescription
templateStringArray<string>true-template strings.

Returns

A function which returns the sanitized html string.

Usage

const env = muze();
const canvas = env.canvas();

canvas.title(html`<span style=font-size:20px;>TITLE</span>`);

share

Syntax: share(...measures)

Creates a new composed variable instance from multiple variables. This is required when we need to map multiple fields in a single axis. For example, we want to show minimum temperature and maximum temperature on y-axis, then we have to create a shared field.

Parameters:

PropertyTypeRequiredDefaultDescription
measuresstringtrue-Measure names

Returns

Variable instance.

Usage

const env = muze();
const canvas = env.canvas();
const { share } = muze.Operators;

const sharedField = share('maxTemp', 'minTemp');

canvas.rows([sharedField])
  .columns(['date'])
  .mount('#chart');